import getProducts from '../../api'

const state = {
  all: []
}

const mutations = {
  setAll(state, all) {
    state.all = all
  }
}

const actions = {
  async loadProducts({ commit }) {
    const result = await getProducts()
    commit('setAll', result)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}